home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Online / httpproxy / src / httpproxy.h < prev    next >
C/C++ Source or Header  |  1996-08-20  |  6KB  |  185 lines

  1. /*(( "Header" */
  2. /*
  3.  * $Id: httpproxy.h,v 1.10 1996/08/20 17:36:43 mshopf Exp mshopf $
  4.  *
  5.  * (c) 1995-96 Matthias Hopf
  6.  */
  7.  
  8. /*
  9.  * $Log: httpproxy.h,v $
  10.  * Revision 1.10  1996/08/20  17:36:43  mshopf
  11.  * changed DEFAULT_DELTIME, added QueueMode, DEFAULT_MIN_REQUESTS.
  12.  *
  13.  * Revision 1.9  1996/08/12  03:33:36  mshopf
  14.  * added Url field in request_t.
  15.  *
  16.  * Revision 1.8  1996/08/11  22:25:15  mshopf
  17.  * reworked debug messages.
  18.  *
  19.  * Revision 1.7  1996/07/30  13:57:03  mshopf
  20.  * reserved the last 256 bytes in the databuffer for error messages.
  21.  *
  22.  * Revision 1.6  1996/07/17  16:42:42  mshopf
  23.  * support for new cache system.
  24.  *
  25.  * Revision 1.5  1996/06/06  23:01:23  mshopf
  26.  * added AlwaysReload
  27.  *
  28.  * Revision 1.4  1996/06/03  04:08:19  mshopf
  29.  * added timeout values.
  30.  * added connection error state.
  31.  *
  32.  * Revision 1.3  1996/04/26  05:14:03  mshopf
  33.  * move network encapsulation to net.h
  34.  * V0.13 alpha 5 fix.
  35.  *
  36.  * Revision 1.2  1996/04/24  17:41:16  mshopf
  37.  * config changes.
  38.  * net handler enhancement.
  39.  *
  40.  * Revision 1.1  1996/04/24  03:20:13  mshopf
  41.  * Initial revision
  42.  *
  43.  */
  44.  
  45. /*)) */
  46.  
  47. #ifndef _HTTPPROXY_H__
  48. #define _HTTPPROXY_H__
  49.  
  50. /* not nice - to be reviced */
  51. #include "cache.h"
  52.  
  53. #include "debug.h"
  54.  
  55. #include <stdio.h>
  56. #include <dos.h>
  57. #include <dos/datetime.h>
  58.  
  59. /*(( "Defaults" */
  60.  
  61. #define DEFAULT_PROXYPORT 8080
  62. #define DEFAULT_TIMEOUT  (10*60)         /* default: timeout (10 mins) */
  63. #define DEFAULT_DELTIME  (710*24*60*60)  /* default: delete cached files on startup - two years - httpdelete should do that */
  64. #define DEFAULT_EXPIRETIME (7*24*60*60)  /* default: delete cache, when the page is requested and too old */
  65. #define DEFAULT_RELOADTIME 10            /* default: expire cache on reload inbetween */
  66. #define DEFAULT_MAX_REQUESTS 16          /* Maximum number of pending requests */
  67. #define DEFAULT_MIN_REQUESTS 12          /* Minimum number of free requests for interactive actions */
  68.  
  69. /*)) */
  70. /*(( "Constants" */
  71.  
  72. #define NAME_CACHETABLE   ".cachetable"
  73.  
  74. #define MIN_REQUESTS     12       /* Minimum number of free requests for interactive actions */
  75. #define MAX_FILENAME     20       /* maximum size of filename (>= 20) */
  76. #define MAX_URLSAVE      128      /* maximum size of saved url requests */
  77. #define MAX_URLBUFFER    512      /* no Url of any request may be larger than this value (<=MAX_REQBUFFER) */
  78. #define MAX_REQBUFFER    1024
  79. #define MAX_DATABUFFER   2048
  80. #define RESERVED_DATABUFFER 256   /* reserved for error messages */
  81. #define SHIFT_DATABUFFER 512      /* when x bytes are in the data buffer, shift it after send() */
  82. #define SHIFT_REQBUFFER  512      /* dto. for the request buffer */
  83.  
  84. #define MAX_HOSTNAMELEN  64       /* maximum number of characters of the hostname saved */
  85.  
  86. #ifndef FALSE
  87. #define FALSE            (0)
  88. #define TRUE             (1)
  89. #endif
  90.  
  91. /*)) */
  92. /*(( "Flags" */
  93.  
  94. #define REQ_REQSOCKET    0x01     /* a request socket is open */
  95. #define REQ_CONNSOCKET   0x02     /* a connection socket is open / to be connected */
  96. #define REQ_DONE         0x04     /* the connection socket is already closed */
  97. #define REQ_REQDONE      0x08     /* the URL is completely read (cache may be sent) */
  98. #define REQ_HTTP1X0      0x10     /* the URL was sent with HTTP/1.0 */
  99. #define REQ_URLDONE      0x40     /* the URL request (the first) line is already there */
  100. #define REQ_URLINBUFFER  0x80     /* the valid URL description can be found '\0'-terminated in the
  101.                    * UrlBuffer entry, not in any cache entry (proxy only mode) */
  102. #define REQ_LOGGED       0x100    /* The request is already logged (error/message information) */
  103. #define REQ_CONNERR      0x200    /* Error while trying to open connection socket */
  104.  
  105. #define REQ_NEWCACHE     0x400    /* We're writing into a new cachefile */
  106.  
  107. #define REQ_PENDINGMASK  0x03     /* There is any Connection pending */
  108.  
  109. /*
  110.  * Some typical Flag combinations in typical order:
  111.  * None:                           Empty slot
  112.  * REQ_REQSOCKET:                  Awaiting URL
  113.  * REQ_REQSOCKET | REQ_CONNSOCKET: Still geting URL, but 1. line is already there
  114.  *                                   *or*  URL done
  115.  *                                 Awaiting connection to remote host
  116.  *                                   *or*  already transfering data
  117.  * REQ_REQSOCKET | REQ_DONE:       The connection socket is already closed, but data is
  118.  *                                   still to be delivered, or data is sent from the cache
  119.  * REQ_CONNSOCKET:                 Request was terminated, still geting data to fill up
  120.  *                                   the cache.
  121.  */
  122.  
  123. /* REQ_REQSOCKET: alone will never occour on ProxyProxy==TRUE... */
  124.  
  125.  
  126. /*)) */
  127. /*(( "Makros" */
  128.  
  129.                   /* Needed Memory */
  130. #define NEED_MEM         ((MaxRequests * sizeof (request_t)) / 1024)
  131.  
  132. #define difftime(x,y)    (((u_long)(x)) - ((u_long)(y)))
  133. #define isvalidhttp(x)   ((unsigned char)(x) > ' ' && (x) != '%' && (x) != '\\' && (unsigned char)(x) < 128)
  134.  
  135. /*)) */
  136. /*(( "Types" */
  137.  
  138. #if 0
  139. typedef struct {
  140.            int  Flags;
  141.            char File [MAX_FILENAME];        /* "" if free slot / with begining '_' (data) */
  142.            char Url  [MAX_URLSAVE];         /* "" if free slot or just getting data */
  143.            } cache_t;
  144. typedef struct cachearray {
  145.                   struct cachearray *Next;
  146.                   cache_t Caches [MAX_CACHES];
  147.               } cachearray_t;
  148. #endif
  149.  
  150. typedef struct _request {
  151.            int   ReqSocket, ConnSocket;
  152.            int   Flags;
  153.            char  Address    [MAX_HOSTNAMELEN];
  154.            char  Url        [MAX_URLSAVE];
  155.            char  ReqBuffer  [MAX_REQBUFFER];
  156.            char  UrlBuffer  [MAX_URLBUFFER];/* This one contains the URL line for sending the request */
  157.            char  DataBuffer [MAX_DATABUFFER];
  158.            int   ReqSent, ReqRecv;
  159.            int   UrlSent, UrlRecv;
  160.            int   DataSent, DataRecv;
  161.            cachefile_t Cache;
  162.            struct DateStamp LastStamp;      /* last access time for timeouts */
  163.            } request_t;
  164.  
  165. /*)) */
  166. /*(( "Global Variables" */
  167.  
  168. extern request_t *Requests;
  169. extern int OffLine;
  170. extern int GetQueued;
  171. extern int AlwaysReload;
  172. extern int QueueMode;
  173. extern struct DateStamp RequestStamp;               /* Current time while the request is processed */
  174.  
  175. /*)) */
  176.  
  177. extern void ExitAll (int);
  178. extern void CheckGetQueued (int);
  179. extern int  ScanService (request_t *, const char *);
  180. extern void ErrToReq (request_t *, int, int, const char *, const char *, const char *);
  181. extern void ShutdownConnects (void);
  182.  
  183. #endif /* _HTTPPROXY_H__ */
  184.  
  185.